// page/account/bindphone.js
Page({
  data: {
        isHide: 0,
        btnType: "default",
        disabled: true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
        var that = this
        that.setData({
            isHide: 1
        })
  },

  formSubmit: function (e) {
      var phone = e.detail.value.txtPhone
      // var code = e.detail.value.txtCode 
      if(phone.length < 1){
        wx.showModal({
            title: '提示',
            content: '请输入手机号码',
            showCancel: false
        })
      }
      // else if(code.length < 1){
      //   wx.showModal({
      //       title: '提示',
      //       content: '请输入验证码',
      //       showCancel: false
      //   })
      // }
      var app = getApp()
      var that = this;
      var uid = wx.getStorageSync('uid');
      wx.request({
        url: app.globalData.host + '&g=App&m=Cart&a=upphone', //仅为示例，并非真实的接口地址
        data: { uid: uid, phone: phone},
        header: {
          'content-type': 'application/json'
        },
        success: function (res) {
        //  console.log(res.data)
            wx.showToast({
              title: '设置成功',
              icon: 'success',
              duration: 2000
            })
            wx.navigateBack({
              delta: 1
            })
          
        }
      });
  },
  switchBtn: function () {
      this.setData({
          btnType: "warn",
          disabled: false         
      })
  }
})